#pragma	once

#include "ZOdbcPrerequisite.h"
#include "ZOdbcParameter.h"
#include <sql.h>
#include <sqlext.h>
#include <boost/shared_ptr.hpp>

namespace	Z	{

namespace	Odbc	{

//------------------------------------------------------------------------------------------------------------------------
class	_ZOdbcApi	Command
{
public:
	Command(Connection& kConnection);
	~Command();
	RecordsetPtr	execute();
	void	setCommandText(const char* format, ...);
	void	setCommandText(const char* format, va_list args);
	template<typename T>	void	addParameter(T t)	{	mParameters.add(t, mConnection);	}
	void	addParameter(const std::string& str)	{	mParameters.add(str, mConnection);		}
	void	addParameter(const Z::Stream& stream)	{	mParameters.add(stream, mConnection);	}
private:
	bool	execDirect(Recordset& kRecordset);

private:
	std::string	mCommandText;
	Parameters	mParameters;
	Connection&	mConnection;
};

}

}